//////////////////////////////////////////////////////////////////////////////////
//
//	AvaMods BotMod2
//		- Version 1.0
//		- 11.30.2007
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
//	A much more basic & simple version of the original botmod:
//		- Clears bot's score on join
//		- Does not allow bots to be sniper/deployable classes
//
//////////////////////////////////////////////////////////////////////////////////
//
// Changelog:
//
//	- 06.05.2007 Version 0.1beta
//		added random class changes
//
// 	- 06.07.2007 Version 0.2beta
//		changed way brits change class (AvaMods Player Models plugin will now catch it)
//
// 	- 11.30.2007 Version 1.0
//		Initial Public Release
//
//////////////////////////////////////////////////////////////////////////////////



#include <amxmodx>
#include <dodfun>
#include <dodx>

public plugin_init()
{
	register_plugin("AvaMods BotMod2", "1.0", "diamond-optic")
	register_cvar("avamods_botmod2_stats", "1.0", FCVAR_SERVER|FCVAR_SPONLY)
	
	register_event("ResetHUD", "player_spawn", "be")
}

public client_putinserver(id)
{
  if(is_user_bot(id) && is_user_connected(id))
	{
	set_task(0.3, "change_class", id)
	
	set_task(0.5, "bot_score", id)
	}
}

public client_disconnect(id)
{
	if(is_user_bot(id) && task_exists(id))
		remove_task(id)
}

public player_spawn(id)
{
	if(is_user_bot(id) && random_num(0,1) == 1)
		change_class(id)	
}

public change_class(id)
{
	if(is_user_bot(id) && is_user_connected(id))
		{
		new team = get_user_team(id)
			
		if(team == 1 && dod_get_map_info(MI_ALLIES_TEAM) == 1)	//allies & brits?
			{
			switch(random_num(0, 1))
				{
				case 0: engclient_cmd(id,"cls_enfield") //dod_set_user_class(id, DODC_ENFIELD)
				case 1: engclient_cmd(id,"cls_sten")	//dod_set_user_class(id, DODC_STEN)
				}
			}
		else if(team == 1)	//allies
			{
			switch(random_num(0, 3))
				{
				case 0:	dod_set_user_class(id, DODC_GARAND)
				case 1:	dod_set_user_class(id, DODC_CARBINE)
				case 2:	dod_set_user_class(id, DODC_GREASE)
				case 3:	dod_set_user_class(id, DODC_THOMPSON)
				}
			}
		else if(team == 2)	//axis
			{
			switch(random_num(0, 3))
				{
				case 0:	dod_set_user_class(id, DODC_KAR)
				case 1:	dod_set_user_class(id, DODC_K43)
				case 2:	dod_set_user_class(id, DODC_MP40)
				case 3:	dod_set_user_class(id, DODC_MP44)
				}
			}
		}
}

public bot_score(id)
{
	if(is_user_connected(id) && is_user_bot(id))
		{
		dod_set_user_kills(id, 0, 1)
		dod_set_user_score(id, 0, 1)
		dod_set_pl_deaths(id, 0, 1)
		}
}
